<?php include BASE_PATH.'install/step/header.tpl.php';?>
	<div class="container" style="margin-bottom: 180px;">
		<div id="bar" class="progress progress-striped active" style="margin-top: 100px;">
			<div class="bar" style="width: 75%;"></div>
		</div>
		<div class="well fade in">
			<div class="tabbable tabs-left">
			  <ul class="nav nav-tabs">
				<?php for($i=1; $i<=count($steps); $i++){ ?>
					<li <?php if($step==$i) { ?> class="active" <?php } ?> ><a data-toggle="tab"><?php echo $steps[$i]; ?></a></li>
                <?php } ?>
              </ul>
			  <div class="tab-content">
				<div id="installmessage">
					<p class="text-success">正在准备安装 ...</p>
				</div>
			  </div>
			</div>
		</div>
		<div class="row-fluid">
			<div class="span2 offset5">
				<a href="javascript:void(0);"  onClick="$('#install').submit();return false;" class="btn btn-large btn-block btn-primary disabled">安装中..</a>
			</div>
		</div>
	</div>
	<form id="install" action="install.php?" method="post">
	<input type="hidden" name="module" id="module" value="<?php echo $module?>" />
	<input type="hidden" id="selectmod" name="selectmod" value="<?php echo $selectmod?>" />
	<input type="hidden" name="step" value="7">
	</form>
</body>
<script src="../static/js/jquery.js"></script>
<script type="text/javascript">
$().ready(function() {
reloads();
})
var n = 0;
var setting =  new Array();
setting['admin'] = '后台管理主模块安装成功......';
var dbhost = '<?php echo $dbhost?>';
var dbuser = '<?php echo $dbuser?>';
var dbpw = '<?php echo $dbpw?>';
var dbname = '<?php echo $dbname?>';
var tablepre = '<?php echo $tablepre?>';
var dbcharset = '<?php echo $dbcharset?>';
var username = '<?php echo $username?>';
var password = '<?php echo $password?>';
var email = '<?php echo $email?>';
function reloads() {
	var module = $('#selectmod').val();
	m_d = module.split(',');
	$.ajax({
		   type: "POST",
		   url: 'install.php',
		   data: "step=installmodule&module="+m_d[n]+"&dbhost="+dbhost+"&dbuser="+dbuser+"&dbpw="+dbpw+"&dbname="+dbname+"&tablepre="+tablepre+"&dbcharset="+dbcharset+"&username="+username+"&password="+password+"&email="+email+"&sid="+Math.random()*5,
		   success: function(msg){
			   if(msg==1) {
				   alert('指定的数据库不存在，系统也无法创建，请先通过其他方式建立好数据库！');
			   } else if(msg==2) {
				   $('#installmessage').append('<p class="text-error">'+m_d[n]+'/install/mysql.sql 数据库文件不存在</p>');
			   } else if(msg.length>20) {
				   $('#installmessage').append('<p class="text-error">错误信息：'+msg+'</p>');
			   } else {
				   $('#installmessage').append('<p class="text-success">'+setting[m_d[n]] + msg + '<i class="icon-ok"></i></p>');				   
					n++;
					if(n < m_d.length) {
						reloads();
					} else {
						$('#installmessage').append('<p class="text-success">安装完成<i class="icon-ok"></i></p>');
						/*var testdata = $('#testdata').val();
						if(testdata == 1) {
							$('#hiddenop').load('?step=testdata&sid='+Math.random()*5);
							$('#installmessage').append("<font color='yellow'>测试数据安装完成</font><br>");
						}						
						$('#hiddenop').load('?step=cache_all&sid='+Math.random()*5);						
						$('#installmessage').append("<font color='yellow'>缓存更新成功</font><br>");
						$('#installmessage').append("<font color='yellow'>安装完成</font>");
						$('#finish').removeClass('pre');
						$('#finish').html('安装完成');*/
						//setTimeout("$('#install').submit();",1000); 						
					}
			   }	
		}	
		});
}
</script>
</html>